#define _CRT_SECURE_NO_WARNINGS 1

class FindSumPairs {
public:
    FindSumPairs(vector<int>& nums1, vector<int>& nums2) {
        for (auto& val : nums2) _value_count[val]++;
        array_1 = nums1;
        array_2 = nums2;
    }

    void add(int index, int val) {
        _value_count[array_2[index]]--;
        array_2[index] += val;
        _value_count[array_2[index]]++;
    }

    int count(int tot) {
        int res = 0;
        for (auto& val : array_1)
        {
            res += _value_count[tot - val];
        }
        return res;
    }
private:
    unordered_map<int, int> _value_count;
    vector<int> array_1;
    vector<int> array_2;
};

/**
 * Your FindSumPairs object will be instantiated and called as such:
 * FindSumPairs* obj = new FindSumPairs(nums1, nums2);
 * obj->add(index,val);
 * int param_2 = obj->count(tot);
 */